from airtest.core.api import *
import logging
import random
import string

logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR)

def wallet_name(length: int) -> str:
    """生成包含大小写字母和数字的随机字符串"""
    # 定义字符集：大小写字母 + 数字
    characters = string.ascii_letters + string.digits  # 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
    # 从字符集中随机选择length个字符，拼接成字符串
    return ''.join(random.choice(characters) for _ in range(length))

print("开始")

auto_setup(__file__, devices=["Windows:///?title_re=.*Cregis.*"])
sleep(1)
#标题链接窗口

touch(Template(r"D:\AIRtest\UDun_UI\index\153328.png"))
sleep(1)
text("1442055324819456")
sleep(1)
touch(Template(r"D:\AIRtest\UDun_UI\index\154039.png"))
sleep(1)
#选择商户

text("2530033961@qq.com")
touch(Template(r"D:\AIRtest\UDun_UI\index\tpl1760345484680.png", record_pos=(0.278, -0.0), resolution=(1311, 823))),
sleep(1.0)
#选择登录账号

text("Asdfghjkl")
sleep(1.0)
#填写密码

touch(Template(r"D:\AIRtest\UDun_UI\index\tpl1760343437338.png", record_pos=(0.293, 0.096), resolution=(1311, 823))),
sleep(1.0)
#点击登录

touch(Template(r"D:\AIRtest\UDun_UI\index\085605.png"))
sleep(1.0)
#点击新建钱包

text(wallet_name(10))
sleep(1.0)

touch(Template(r"D:\AIRtest\UDun_UI\index\tpl1760346015429.png", record_pos=(-0.47, 0.331), resolution=(1136, 823))),
sleep(1.0)
# 进入个人界面

touch(Template(r"D:\AIRtest\UDun_UI\index\tpl1760346026127.png", record_pos=(-0.184, 0.243), resolution=(1136, 823)))
#退出登录


print("over")



